<!-- END container -->
<div style="text-align:center;margin-top: 2em;background: #fff;border-top: #28cad2 solid 1px;padding-top: 15px;padding-bottom: 10px;">
    <a href="https://www.yuque.com/u589148/sc" target="_blank">生存战争百科</a>&emsp;当前在线:{$onlinecnt}人&emsp;<a href="/com/statistics">更多信息</a>
</div>
<script type="text/javascript">
var a_idx = 0;
jQuery(document).ready(function($) {
    $("body").click(function(e) {
        var a = new Array("❤","❤","❤","❤","❤","❤","❤","❤","❤","❤","❤","❤");
        var $i = $("<span></span>").text(a[a_idx]);
        a_idx = (a_idx + 1) % a.length;
        var x = e.pageX,
        y = e.pageY;
        $i.css({
            "z-index": 999999,
            "top": y - 20,
            "left": x,
            "position": "absolute",
            "font-weight": "bold",
            "color": "rgb("+~~(255*Math.random())+","+~~(255*Math.random())+","+~~(255*Math.random())+")"
        });
        $("body").append($i);
        $i.animate({
            "top": y - 180,
            "opacity": 0
        },
        1500,
        function() {
            $i.remove();
        });
    });
});

</script>
<script>
    $(window).trigger("action:ajaxify.start", {});
    $(window).trigger("action:ajaxify.end", {});
    $(window).trigger("action:ajaxify.loadingTemplates", {});
    $(window).trigger("action:ajaxify.contentLoaded", {});
    $(window).trigger("action:ajaxify.loadingData", {});
    $(window).trigger("action:ajaxify.dataLoaded", {});
    
    setupProgressBar();
    animateCategoryCards();
    setupSideBar();
    setupFloatingLabels();
    setupMenus();
    setupChatSearch();
    setupCheckBox();
    autoCloseMsg();
    
    function setupProgressBar() {
        $(window).on('action:ajaxify.start', function() {
            $('.material-load-bar').css('height', '3px');
        });
        $(window).on('load', function() {
            $('.material-load-bar').css('height', '3px');
            setTimeout(function(){ $('.material-load-bar').css('height', '0px'); }, 1000);
            
        });

        $(window).on('action:ajaxify.end', function(ev, data) {
            setTimeout(function(){ $('.material-load-bar').css('height', '0px');}, 1000);
            setTimeout(function(){
            //页面加载完成自动回到顶部
            var top = document.body.scrollTop || document.documentElement.scrollTop
            scrollBy(0,-top);
            },200);
        });
    }
    
    function animateCategoryCards() {
        $(window).on('action:ajaxify.end', function() {
            var speed = 2000;
            var container =  $('.display-animation');
            container.each(function() {
                var elements = $(this).children();
                elements.each(function() {
                    var elementOffset = $(this).offset();
                    var offset = elementOffset.left*0.8 + elementOffset.top;
                    var delay = parseFloat(offset/speed).toFixed(2);
                    $(this)
                        .css("-webkit-animation-delay", delay+'s')
                        .css("-o-animation-delay", delay+'s')
                        .css("animation-delay", delay+'s')
                        .addClass('animated');
                });
            });
        });
    }
    //电脑登录退出
    function logout(){
        if(confirm('你确定要退出吗'))window.location.href="/com/logout";
    }
    
    function setupSideBar() {
      
        $('body').on('click', '#menu-trigger', function(e){            
            e.preventDefault();
            var x = $(this).data('trigger');
        
            $(x).toggleClass('toggled');
            $(this).toggleClass('open');

            
            if (x == '#sidebar') {
                $elem = '#sidebar';
                $elem2 = '#menu-trigger';
                
                if (!$('#chat').hasClass('toggled')) {
                    $('#header').toggleClass('sidebar-toggled');
                }
            }
            
            //When clicking outside
            if ($('#header').hasClass('sidebar-toggled')) {
                $(document).on('click', function (e) {
                    if (($(e.target).closest($elem).length === 0) && ($(e.target).closest($elem2).length === 0)) {
                        setTimeout(function(){
                            $($elem).removeClass('toggled');
                            $('#header').removeClass('sidebar-toggled');
                            $($elem2).removeClass('open');
                        });
                    }
                });
            }
        });

  
        //Get saved layout type from LocalStorage
        var layoutStatus = localStorage.getItem('ma-layout-status');
        if (layoutStatus == 1 && !config.menuInHeader) {
           $('body').addClass('sw-toggled');
           $('#tw-switch').prop('checked', true);
        }

        $('body').on('change', '#toggle-width input:checkbox', function(){
           if ($(this).is(':checked')) {
           $('body').addClass('toggled sw-toggled');
           localStorage.setItem('ma-layout-status', 1);
           }
           else {
           $('body').removeClass('toggled sw-toggled');
           localStorage.setItem('ma-layout-status', 0);
           }
        });

        $(window).on('action:ajaxify.start', function() {
            if ($('#menu-trigger').hasClass('open')) {
                $('#menu-trigger').click();
            }
        });
    }
    
    function setupFloatingLabels() {
        $(window).on('action:ajaxify.end', function() {
            //Add blue animated border and remove with condition when focus and blur
            if($('.fg-line')[0]) {
                $('body').on('focus', '.form-control', function(){
                    $(this).closest('.fg-line').addClass('fg-toggled');
                })

                $('body').on('blur', '.form-control', function(){
                    var p = $(this).closest('.form-group, .input-group');
                    var i = p.find('.form-control').val();
                    
                    if (p.hasClass('fg-float')) {
                        if (i.length == 0) {
                            $(this).closest('.fg-line').removeClass('fg-toggled');
                        }
                    }
                    else {
                        $(this).closest('.fg-line').removeClass('fg-toggled');
                    }
                });
            }

            //Add blue border for pre-valued fg-flot text feilds
            if($('.fg-float')[0]) {
                $('.fg-float .form-control').each(function(){
                    var i = $(this).val();
                    
                    if (!i.length == 0) {
                        $(this).closest('.fg-line').addClass('fg-toggled');
                    }
                    
                });
            }
        });
    }
    
    function setupMenus() {
        $(window).on('action:ajaxify.start', function() {

            if ($('.chats.dropdown').hasClass('open')) {
                $('.chats.dropdown').click();
            }

            if ($('.notifications.dropdown').hasClass('open')) {
                $('.notifications.dropdown').click();
            }
        });

        $('body').on('click', '#chat-list>li', function(e){
            if ($('.chats.dropdown').hasClass('open')) {
                $('.chats.dropdown').click();
            }
        });

        $('body').on('click', '#user-control-list>li', function(e){
            if ($('#user_label').hasClass('open')) {
                $('#user_label').click();
            }
        });

        $('body').on('click', '#ms-menu-trigger', function(e){            
            e.preventDefault();
            $(this).toggleClass('open');
            $('.ms-menu').toggleClass('toggled');
        });

        $('body').on('click', '.ms-menu .chats-list>li', function(e){
            if ($('#ms-menu-trigger').hasClass('open')) {
                $('#ms-menu-trigger').toggleClass('open');
                $('.ms-menu').toggleClass('toggled');
            }
        });
        
    }
    function setupChatSearch() {
        $(window).on('action:ajaxify.end', function() {
             $('body').on('click', '.new-chat', function(e){            
                e.preventDefault();
                $('.chat-search-menu').addClass('toggled');
                $('[component="chat/search"]').focus();
            });
        
            $(document).keyup(function(e) {
                if (e.keyCode === 27 && $('.chat-search-menu').hasClass('toggled')) {
                    $('.chat-search-menu').removeClass('toggled');
                    $('[component="chat/search"]').val('');
                }
            });
            
            $('body').on('click', '#chat-search-menu-trigger', function(e){ 
                $('.chat-search-menu').removeClass('toggled');
                $('[component="chat/search"]').val('');
                $('[component="chat/search/list"]').empty();
            });
        });
    }
    function setupCheckBox() {
        $(window).on('action:ajaxify.end', function() {
            if (ajaxify.data.template.name == 'registerComplete') {
                $('#agree-terms').after('<i class="input-helper"></i>');
            }
        });
    }
    function autoCloseMsg(){
        var dp=$(".alert-window");
        if(!dp.hasClass('hide'))setTimeout('closeMsg()',2000);
    }


</script>
<!--<script>
    $(document).ready(function () {
        $('#content').ajaxify();
    });
</script>-->
<script>
function closeMsg(){
    $(".alert-window").addClass('hide');
}
function zanb(id){
    $.ajax({
        url:"/com/api/bbs/goods/?bid="+id,
        method:"GET",
        dataType:'json',
        success:function(res){
            layui.layer.msg(res.msg);
            if(res.code==200){
                $('#zanb'+id).html(res.data.data);
            }
        }
    });
}
function zanr(id){
    $.ajax({
        url:"/com/api/bbs/goods/?rid="+id,
        method:"GET",
        dataType:'json',
        success:function(res){
            layui.layer.msg(res.msg);
            if(res.code==200){
                $('#zanr'+id).html(res.data.data);
            }
        }
    });
}
function caib(id){
    $.ajax({
        url:"/com/api/bbs/bads/?bid="+id,
        method:"GET",
        dataType:'json',
        success:function(res){
            layui.layer.msg(res.msg);
            if(res.code==200){
                $('#caib'+id).html(res.data.data);
            }
        }
    });
}
function cair(id){
    $.ajax({
        url:"/com/api/bbs/bads/?rid="+id,
        method:"GET",
        dataType:'json',
        success:function(res){
            layui.layer.msg(res.msg);
            if(res.code==200){
                $('#cair'+id).html(res.data.data);
            }
        }
    });
}
function bindID(id){
    return document.getElementById(id);
}
</script>